<template>
  <div class="header-info">
    <div class="operation">
      <span>
        <el-icon><Message /></el-icon>
      </span>
      <span>
        <span class="dot"></span>
        <el-icon><Bell /></el-icon>
      </span>
      <span>
        <el-icon><Search /></el-icon>
      </span>
    </div>

    <div class="info">
      <el-dropdown>
        <span class="user-info">
          <el-avatar
            :size="30"
            src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"
          />
          <span class="user-name">{{ loginStore.userName }}</span>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item @click="handLogout">
              <el-icon><CircleClose /></el-icon>
              <span>退出登录</span>
            </el-dropdown-item>
            <el-dropdown-item divided>
              <el-icon><Warning /></el-icon>
              <span>个人信息</span>
            </el-dropdown-item>
            <el-dropdown-item>
              <el-icon><Lock /></el-icon>
              <span>修改密码</span>
            </el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'

import useLoginStore from '@/store/login/login'
const loginStore = useLoginStore()

function handLogout() {
  loginStore.logout()
}
</script>

<style scoped lang="less">
.header-info {
  display: flex;
  align-items: center;
  .operation {
    display: inline-flex;
    margin-right: 20px;

    span {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 40px;
      height: 35px;
      &:hover {
        background: #f2f2f2;
      }
      i {
        font-size: 20px;
      }
      .dot {
        position: absolute;
        top: 3px;
        right: 3px;
        z-index: 10;
        width: 6px;
        height: 6px;
        background: red;
        border-radius: 100%;
      }
    }
  }
  .info {
    .user-info {
      display: flex;
      align-items: center;
      outline-width: 0px;

      .user-name {
        cursor: pointer;
        margin-left: 10px;
      }
    }
  }

  .info {
    // 设置全局样式，不局限于#app，整个html里面的都可以
    :global(.el-dropdown-menu__item) {
      line-height: 36px !important;
      padding: 6px 22px;
    }
    // 这样设置是不生效的，这样写默认元素是在#app里面，实际上元素不在
    // ::v-deep .el-dropdown-menu__item {
    //   line-height: 36px !important;
    //   padding: 6px 22px;
    // }
  }
}
</style>
